//
//  MyAppointmentViewCell.swift
//  iModern
//
//  Created by Ralf on 6/3/15.
//  Copyright (c) 2015 com.starlooking. All rights reserved.
//

import UIKit

class MyAppointmentViewCell: AdvertisingCell
{
    override func awakeFromNib()
    {
        self.removeSomeControlsFromSuperView()
        super.awakeFromNib()
    }

    override func setSelected(selected: Bool, animated: Bool)
    {
        super.setSelected(selected, animated: animated)
    }

    func setData(data: NSMutableDictionary)
    {
        //let appointment = data
        let advertising = data["advertising"] as! NSDictionary
        let contact     = advertising["contact"] as! NSDictionary

        setAliasLabel(contact["alias"] as! String)
        setNumberOfFavoritesButton(String(advertising["numberOfFavorites"] as! Int))
        setNumberOfCommentsButton(String(advertising["numberOfComment"] as! Int))
        setAvatarImageView(contact["thumbnailURL"] as? String)
        setPreviewImageView(advertising["imageURL"] as! String)

        setSummaryLabel(advertising["summary"] as! String)
    }
    //临时决绝办法。没解决根本原因
    func removeSomeControlsFromSuperView()
    {
        let label = self.viewWithTag(__alias_label_tag) as! UILabel
        label.removeFromSuperview()
        let imageView = self.viewWithTag(__avatar_image_view_tag) as? UIImageView
        imageView?.removeFromSuperview()
        let numberoffavorites = self.viewWithTag(__number_of_favorites_button_tag) as! UILabel
        numberoffavorites.removeFromSuperview()

    }
}
